#!/bin/sh

REMOTE_HOST="hitower"
REMOTE_USER="loguser"
SSH_PRIV_KEY="/etc/ssh/keys/loguser"
REMOTE_DIR="/home/loguser/marsrover2"
MOUNTDIR="/mnt/remote"

case "$1" in
  start|restart)
    if test -z "`mount | grep -i shfs | grep $MOUNTDIR`"; then
    	shfsmount -c "ssh -i $SSH_PRIV_KEY $REMOTE_USER@$REMOTE_HOST" $REMOTE_DIR $MOUNTDIR
    else
    	echo "Remote volume already mounted."
    fi
    ;;
   stop)
    if test ! -z "`mount |grep -i shfs|grep $MOUNTDIR`"; then
    	umount $MOUNTDIR
    fi
    ;;
   *)
   	echo "$0 ( start | stop | restart )"
   	;;
esac

exit 0
